package mymyoux.graphics
{
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	//import mx.controls.Button;
	
	public class Test
	{
		protected var root:*;
		protected var g:GraphicFactory;
		protected var x:XML;
		public function Test(root:*)
		{
			this.root=root;
			g=new GraphicFactory(root);
			g.addEventListener("display_loaded",onDisplayed);
			//root.addChild(g.display);
			var loader:URLLoader=new URLLoader();
			var url:URLRequest= new URLRequest("interface.xml");
			loader.load(url);
			loader.addEventListener(Event.COMPLETE,onComplete);
			loader.addEventListener(IOErrorEvent.IO_ERROR,onError);
			loader.addEventListener(ProgressEvent.PROGRESS,onProgress);
		}
		public function onProgress(event:ProgressEvent):void
		{
			trace(event);
		}
		public function onComplete(event:Event):void
		{
			x=new XML((event.target as URLLoader).data);
			g.load(x);
		}
		public function onError(event:IOErrorEvent):void
		{
			trace("ioerror:"+event);
		
		}
		protected function onDisplayed(event:Event):void
		{
			g.getChild("bouton1").label="coucou";
			g.getChild("bouteson").label="hihi";
			g.getChild("boutesasson").label="hihi";
			g.getChild("sas1").width=800;
			g.connect("clickbouton",onClick);
			g.connect("clickbouton",onClick2);
			g.connect("doubleclic",onDoubleClick);
			g.disconnect("clickbouton",onClick2);
			g.connect("click",onClick);
		//	g.addChild(new Button(),"bou","bouston");
		//	g.addEvent("bou","clickbouton","mouseOver");
			//g.removeChild("bouton");
			//g.removeChild("surcarre");
			g.removeEventListener("display_loaded",onDisplayed);
			g.clearChild("surcarre");
			g.load(x,"surcarre");
		}
		protected function onClick(event:Event):void
		{
			trace("CLICK");
		}
		protected function onClick2(event:Event):void
		{
			trace("CLICK2");
		}
		protected function onDoubleClick(event:Event):void
		{
			trace("Doubleclick:"+event);
		}

	}
}